Set-Location -Path (Split-Path -Path $MyInvocation.MyCommand.Definition -Parent)
Write-Host "Path switch successful"
$condaProfile = "$env:USERPROFILE\Documents\WindowsPowerShell\profile.ps1"
. $condaProfile
# 定义 Conda 环境的名称
$condaEnvironment = $env:ENVIRONMENT_NAME
$pythonVersion = $env:PYTHON_VERSION
$mainFileName = $env:MAIN_FILENAME

# 检查 Conda 环境是否存在
$condaEnvironmentExists = conda env list | Select-String -Pattern $condaEnvironment+" "

if ($condaEnvironmentExists) {
    # 如果环境存在，则激活它
    Write-Host "Conda environment '$condaEnvironment' exist, try to activate."
    conda activate $condaEnvironment
    Write-Host "Conda environment '$condaEnvironment' activated."
} else {
    # 如果环境不存在，则创建它并激活
    conda create --name $condaEnvironment python=$pythonVersion -y
    conda activate $condaEnvironment
}

$requirementsPath = (Get-Item -Path .\requirements.txt).FullName

pip install -r $requirementsPath